﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using FrameWork;

namespace uu.Pages
{ 
    [WebPage("/[%tablename%]/")]
    public class [%Utablename%]Page : Page
    {
        public [%Utablename%]Page()
            : base("/a/html/[%tablename%].htm", true)
        {

            template.Set("ID", CurrentUser.fb_id);
            template.Set("name", CurrentUser.firstname + " " + CurrentUser.lastname);
            

            [%Utablename%] _[%tablename%] = new [%Utablename%]();
            if (Query["id"].NNOE())
            {
                _[%tablename%] = new [%Utablename%](sb.Long(Query["id"], "invalid id"), val);
            }

            if (isPost)
            { 
                 [%upsert%]
                _[%tablename%].UpSert(sb);
            }
            else
            {
                if ([%tablename%].id != 0)
                { 
                    [%exists%]
                }
            }
        }
    }
}